//
//  ChatMessageMgr.h
//  WxSdk
//
//  Created by fusuwei on 14-9-11.
//  Copyright (c) 2014年 网信金融集团. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "YY_FMDatabase.h"
#import "MessageBase.h"

@interface ChatMessageMgr : NSObject


//check ChatMessage table is create in db
+(BOOL)checkChatMessageTableCreatedInDb:(YY_FMDatabase *)db;

//保存消息对象 MessageBase 到ChatMessage表
+(BOOL)saveChatMessageObj:(MessageBase *)chatMessage;

//保存消息对象 MessageBase 到ChatMessage表
+(BOOL)saveChatMessageObjOnly:(MessageBase *)chatMessage;

//读取某个消息对象  到MessageBase对象中
+(MessageBase *)readChatMessageObjByMsgId:(NSString *)msgId;

//更新指定NSString字段
+(BOOL)saveUpdateMessageId:(NSString*)messageId fieldName:(NSString*)fieldName value:(NSString*)value;

//更新指定NSInteger字段
+(BOOL)saveUpdateMessageId:(NSString*)messageId fieldName:(NSString*)fieldName valueInt:(NSInteger)value;

//更新消息
+(BOOL)updateMessageId:(NSString*)messageId withObj:(MessageBase *)chatMessage;

//获取某联系人聊天记录
+(NSMutableArray*)fetchMessageListWithUser:(NSString *)userId beginIndex:(NSInteger)beginIndex count:(NSInteger)count;

//检查聊天记录中未正常发出的状态
+ (BOOL)checkMessageListAllState;

//删除与某个联系人聊天所有记录
+(BOOL)deleteAllMessageToContactId:(NSString *)contactId;

//查找messageId是否存在
+(BOOL)isFindTheMessageIdExist:(NSString*)messageId;

//获取最近聊天过的联系人最新消息记录列表
+(NSMutableArray *)fetchRecentChatByPage:(NSUInteger)pageIndex;

//获取与某个联系人聊天的未读消息个数
+ (NSInteger)fetchUnreadMsgCountToContactId:(NSString *)contactId;

//删除某条消息
+ (BOOL)deleteMessageId:(NSString *)messageId;

//设置为已读状态
+ (BOOL)setTheMessageIsReaded:(NSString *)messageId;

//设置消息发送状态。服务器收到，对方收到
+ (BOOL)setTheMessageIsSendSuccess:(NSString *)messageId withSendStatus:(NSString *)isSendSuccess;

//获取得到所有未读消息列表
+ (NSMutableArray *)getAllUnReadMessageList;

/**置顶字段设置*/
+(BOOL)saveUpdateConnectId:(NSString*)connecTId fieldName:(NSString*)fieldName valueInt:(NSInteger)value;

//保存置顶信息 到TopConnectIdTab表
+(BOOL)saveTopConnectIdTabcontactId:(NSString *)contactId istop:(NSInteger )istop;
+ (BOOL)checkIsTopState:(NSString *)connectid;
@end
